<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2020/12/1
  Time: 9:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form id="s">
    用户:<input type="text" name="email" >
    密码:<input type="text" name="password" >
    验证码:<input type="text" name="yanzheng" >
    <img src="${pageContext.request.contextPath}/users/yanzheng">
    <button type="button" onclick="login()">登录</button>
    </form>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="js/jquery.serializejson.js"></script>
<script type="text/javascript">
    function login() {
        console.log($("#s").serializeJSON());
        $.ajax({
            url:"users",
            type:"post",
            contentType:"application/json",
            data:JSON.stringify($("form").serializeJSON()),
            success:function (data) {
                console.log(data)
                if (data.success==true){
                    location="show.jsp"
                }else{
                    alert("错误")
                }
            }
        })
    }
</script>
</body>
</html>
